package com.zzyl.controller.customer;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.entity.NursingProject;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @className: CustomerNuringProjectController
 * @description:
 * @author: InnovatorX
 * @date: 2024/5/30 10:47
 * @Version: 1.0
 */
@RestController
@RequestMapping("/customer/orders/project")
public class CustomerNuringProjectController extends ResponseResult {
//    @RequestMapping(value = "/customer/orders/project/page",method = RequestMethod.GET)
    @Autowired
    private NursingProjectService nursingProjectService;

    /**
     * 分页查询护理列表
     * @param name
     * @param status
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public ResponseResult<List<NursingPlanVo>> searchPage(
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "status", required = false) Integer status,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
        PageResponse<NursingProjectVo> pageResponse = nursingProjectService.findByPage(name, status, pageNum, pageSize);
        return success(pageResponse);
    }

    /**
     * 根据编号查询护理项目信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> findById(@PathVariable("id") Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.findById(id);
        return success(nursingProjectVo);
    }
}
